package src.java.medium;

public class Solution215 {
    public int findKthLargest(int[] nums, int k) {
        int[] barrel = new int[20001];
        for (int i = 0; i < nums.length; i++) {
            barrel[nums[i] + 10000]++;
        }
        for (int i = 20000; i >= 0; i--) {
            if (barrel[i] > 0) {
                k-= barrel[i];
                if(k<=0){
                    return i - 10000;
                }
            }
        }
        return -1;
    }
}
